<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/Static/Css/reset.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/zh-cn-system.css" />
<link rel="stylesheet" type="text/css" href="/Static/Css/table_form.css" />
<script src="/Public/js/jquery.min.js"></script>
<script src="/Public/js/jquery.form.js"></script>
<script src="/Public/js/main.js"></script>
<script type="text/javascript" src="/Public/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="/Public/artDialog/plugins/iframeTools.js"></script>
</head>
<body>

<form name="myform" id="myform" method="POST" action="/index.php/admin/add" >
  <input name="id" id="user_id" type="hidden" value="<?php echo ($info["id"]); ?>" />
  <fieldset>
    <legend>管理员信息</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
        <tr>
          <th width="100">用户名：</th>
          <td id="userInput">
          	<?php if(empty($info["username"])): ?><input name="username" id="username" type="text" class="input-text" size="20" value=""  />
                <span class="onShow hidden"></span><span class="orange">设定后不能再修改。</span>
            <?php else: ?>
            	<?php echo ($info["username"]); endif; ?>
          </td>
        </tr>
        <tr>
          <th>密码：</th>
          <td>
          	<input name="password" type="password" id="password" class="input-text" size="20" >
            <span class="onShow"></span>
            <?php if(!empty($info['id'])): ?><span class="orange">留空为不修改！</span><?php endif; ?>
            </td>
        </tr>
        <tr>
          <th>管理员组：</th>
          <td>
          	<select name="role_id" id="role_id">
         	    <option value="0" selected="selected">所属分组</option>
              <?php $_result=get_role_list();if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php echo selected($vo['id'],$info['role_id']);?> /><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
          </td>
        </tr>
        <?php if(($admin) == "1"): ?><tr >
          <th>特殊权限：</th>
          <td style="text-align:left">
          	<input type="checkbox" name="admin" value="1" <?php if(($info['admin']) == "1"): ?>checked="checked"<?php endif; ?> />
            <span class="orange">（允许查看所有电话记录）</span>
		  </td>
        </tr><?php endif; ?>
        <tr class="last">
          <th>启用状态：</th>
          <td style="text-align:left">
          	<input type="radio" name="status" value="1" checked="checked" /> 启用
          	<input type="radio" name="status" value="0" <?php if(($info["status"]) == "0"): ?>checked<?php endif; ?> />停用
		  </td>
        </tr>

      </tbody>
    </table>
  </fieldset>
  <fieldset <?php echo ($hide); ?>>
    <legend>个人信息</legend>
    <table class="table_form" width="100%" cellspacing="0">
      <tbody>
        <tr>
          <th width="100">昵称：</th>
          <td><input name="data[nickname]" id="nickname" class="input-text" type="text" size="20" value="<?php echo ($info["nickname"]); ?>" />
            </td>
        </tr>
        <tr>
          <th>电话：</th>
          <td><input type="text" class="input-text hideborder" name="data[phone]" id="phone" size="20"  value="<?php echo ($info["phone"]); ?>" />
            </td>
        </tr>
        <tr class="last">
          <th>备注：</th>
          <td><textarea name="data[remark]" id="remark" class="input-text" cols="60" rows="4" /><?php echo ($info["remark"]); ?></textarea></td>
        </tr>
      </tbody>
    </table>
  </fieldset>
  <input type="submit" value="提交" class="dialog" id="dosubmit">
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(e) {
	var role_id = "<?php echo ($info["role_id"]); ?>";
	$("#role_id").val(role_id);

    $('#myform').ajaxForm({
			beforeSubmit:  checkForm,
			success:       complete,
			dataType: 'json'
	});

	function checkForm(){
		var user_id = $("#user_id").val();
		var role_id = $("#role_id").val();
		var username  = $("#username").val();
		var password  = $("#password").val();
		if( user_id=='' && username.length<2 ){
			checkInfo('username','姓名不能为空！');
			$('#username').focus();
			return false;
		}
		if( user_id=='' && password.length<6 ){
			//art.dialog({id:'TNCICC',content: '密码不能小于6个字符！',time: 2,icon:'warning'});
			checkInfo('password','密码不能小于6个字符！');
			$('#password').focus();
			return false;
		}

		if(role_id==0){
			art.dialog({id:'TNCICC',content: '请选择分组！',time: 2,icon:'warning'});
			return false;
		}
		return true;
	}
	var origin = $.artDialog.open.origin;
	function complete(data){
		if(data.status==1){
			art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'succeed'});
			setTimeout(function(){origin.location.reload();closeWin()},1500);
		}else{
			art.dialog({id:'TNCICC',content: data.info,time: 1,icon:'warning'});
		}

	}

});

</script>